import java.util.Scanner;

public abstract class User {
    private final String userID;
    private String userPassword;

    private final String userName;
    private final String registerDate;
    private LoginKey userType; //类型和登录密钥一致
    private String userTel;

    protected static final Scanner input = new Scanner(System.in);

    public User(String ID, String password, String name, String date, String tel) {
        userID = ID;
        userPassword = password;
        userName = name;
        registerDate = date;
        userTel = tel;
    }

    public static LoginKey logging() { //登录、登出
        // 登陆界面
        // ...
        System.out.println("请选择: 1.登录  2.退出系统");
        boolean run = false; //是否选择登录
        while(!run) {
            switch (input.next()) {
                case "1":
                    run = true;
                    break;
                case "2":
                    return null;
                default:
                    System.out.println("输入错误，请重新选择： (1.登录  2.退出系统)");
            }
        }
        return Tool.checkIdentify();
    }

    // getter
    public String getUserID() {
        return userID;
    }
    public String getUserName() {
        return userName;
    }
    public String getRegisterDate() {
        return registerDate;
    }
    public LoginKey getUserType() {
        return userType;
    }
    public String getUserTel() {
        return userTel;
    }
    public String getUserPassword() {
        return userPassword;
    }

    // setter
    public void setUserType (LoginKey type) {
        userType = type;
    }
    public void setUserTel (String tel) {
        userTel = tel;
    }
    public void setUserPassword (String password) {
        userPassword = password;
    }
}
